package com.yingwei.util;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.Border;
import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateRenderer extends JLabel implements TableCellRenderer
{
    Border unselectedBorder = null;
    Border selectedBorder = null;
    boolean isBordered = true;

    public DateRenderer(boolean isBordered)
    {
	this.isBordered = isBordered;
	//setOpaque(true); // MUST do this for background to show up.
    }

    public Component getTableCellRendererComponent(JTable table, Object value,
	    boolean isSelected, boolean hasFocus, int row, int column)
    {
	if (value == null)
	{
	    return null;
	}
	if (isSelected)
	{
	    // cell (and perhaps other cells) are selected
	}

	if (hasFocus)
	{
	    // this cell is the anchor and the table has the focus
	}

	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	// Configure the component with the specified value
	setText( format.format(value));

	// Set tool tip if desired
	setToolTipText(value.toString());

	// Since the renderer is a component, return itself
	return this;
    }
}